package com.homegoods.designer.presenter;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.launcher.ARouter;
import com.alibaba.fastjson.JSON;
import com.homegoods.aroutercomment.UserService;
import com.homegoods.classify.model.Constant;
import com.homegoods.designer.DesignerApiUtils;
import com.homegoods.designer.model.DesignerCaseModel;
import com.kedll.library.mvp.AbstractRefreshPresenter;
import com.kedll.library.mvp.BaseModel;
import com.kedll.library.mvp.RefreshingView;

import java.util.List;
import java.util.Random;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * @author QiQi
 * @ClassName: DesignerMoreCasePresenter
 * @date 2018/9/16
 * @description
 */
public class DesignerMoreCasePresenter extends AbstractRefreshPresenter {
    @Autowired
    public UserService userService;


    public DesignerMoreCasePresenter(RefreshingView mView) {
        super(mView);
        ARouter.getInstance().inject(this);
    }

    @Override
    protected void fetchData(boolean isLoadMore) {
        DesignerApiUtils.getMyStylistWorkList(subModelList -> {
            List<DesignerCaseModel> list = JSON.parseArray(subModelList.getItems(), DesignerCaseModel.class);
            parserData(isLoadMore, list);
        }, throwable -> {

        });
//        addSubscription(Observable.range(0, 10)
//                .map(integer -> {
//                    DesignerCaseModel caseModel = new DesignerCaseModel();
//                    caseModel.setHouseType("四室一厅");
//                    caseModel.setImgUrl(Constant.TEST_IMG_URL + new Random().nextInt(20));
//                    caseModel.setSpace("400平");
//                    caseModel.setTitle("古典就是这么美");
//                    caseModel.setId(integer.toString());
//                    return caseModel;
//                })
//                .toList()
//                .subscribeOn(Schedulers.io())
//                .observeOn(AndroidSchedulers.mainThread())
//                .subscribe(caseModels -> parserData(isLoadMore, caseModels)));
    }

    @Override
    protected void addDataItems(List datas) {
//        for (Object data : datas) {
//            adapter.addItem(((BaseModel) data).createItem(id.equals(userService.getUserId()) ? 1 : 0, adapter));
//        }
    }
}
